package forth_exp;

public class WeatherMain {
    public static void main(String[] args)
    {
        Weather weather = new Weather(new Sunny());
        weather.show();

        weather.setState(new Cloudy());
        weather.show();

        weather.setState(new Rainy());
        weather.show();
    }
}

interface WeatherState
{
    public void showState();
}

class Sunny implements WeatherState
{
    public void showState()
    {
        System.out.println("Sunny");
    }
}

class Cloudy implements WeatherState
{
    public void showState()
    {
        System.out.println("Cloudy");
    }
}

class Rainy implements WeatherState
{
    public void showState()
    {
        System.out.println("Rainy");
    }
}

class Weather
{
    public WeatherState state;
    public Weather(WeatherState state)
    {
        this.state = state;
    }
    public void show()
    {
        state.showState();
    }
    public void setState(WeatherState state)
    {
        this.state = state;
    }
}

